import pytest
import allure
from Common import BasePage


@allure.feature("用户登录")
class Test_Kuaikan_Login():

    @pytest.fixture(autouse=True)
    def setup_teardown(self, d):
        # 引入selenium的公共封装函数
        self.basepage = BasePage(d)

        yield

    # @allure.story('用户登录')
    # @allure.severity(allure.severity_level.CRITICAL)
    # @pytest.mark.parametrize(
    #     'Listcases',
    #     YamlReader('project/demo01/data/login.yaml').read_data()['login'])
    # def test_login(self, d, Listcases):
    #     allure.dynamic.title(Listcases.get('title'))  # 获取yaml中的title
    #
    #     # 更改成helium的driver
    #     set_driver(d)
    #
    #     testcase = Listcases['case']
    #     for cases in testcase:
    #         a=list(cases.values())
    #         with allure.step(cases.get("name")):
    #             func=getattr(Helium, a[1])
    #             value=a[2:]
    #             func(*value)
    #         time.sleep(2)
    #
    #     with allure.step("step2：点击登录"):
    #         click(Button("登录"))
    #
    #     assert Text("博客园用户登录").exists() == False, f'{cases["title"]}'


    @allure.story('用户登录成功01')
    @allure.severity(allure.severity_level.CRITICAL)
    def test_login_faild(self, d):
        url = 'https://www.kuaikanmanhua.com'
        self.basepage.open(url)

        self.basepage.click_button(('xpath','//*[@id="HomeHeader"]/div[2]/div/div[2]/div[1]/a[1]/a'),'登录')


#
# @allure.feature("用户登录")
# class Test_Kuaikan_Logins():
#     @allure.story('用户登录成功01')
#     @allure.severity(allure.severity_level.CRITICAL)
#     def test_login_failds(self, d):
#         url = 'https://www.baidu.com'
#         d.get(url)
